function login() {
    var username = $("#username").val();
    var password = $("#password").val();
    if(username && password){
        $.ajax({
            type: "post",
            url: "login/checkAdminLogin",
//                cache:false,
//                async:false,
            dataType: "json",
            data:{
                userName:username,
                password:password,
                loginType:0
            },
            success: function(data){
                if(data == 0){
                    alert("请输入用户名或密码");
                }else if(data == 2){
                    alert("用户名或密码错误");
                }else if(data == 1){
                    window.location.href="index";
                }
            },
            failure:function (result) {
                alert('登陆失败');
            }
        });
    }else{
        alert("请输入用户名或密码");
    }
    event.preventDefault();
}

function loginOut() {
    location.href = "logout";
}

function checkInput(formId) {
    var f = true;
    var requireds = $('#'+formId+ ' .required');
    requireds.each(function () {
        var em = $(this);
        if(em.val() == null || em.val() == "" || em.val() == undefined){
            em.select();
            f = false;
            return false;
        }
    });
    return f;
}

function formFadeOut() {
    $('form').fadeOut(500);
    $('.wrapper').addClass('form-success');
    setTimeout(function () {
        location.href = "/";
    },500);
}
